package src;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileParser {
	private File f;
	private FileInputStream fis;
	private InputStreamReader isr;
	private BufferedReader br;
	private String line;

	public FileParser(String ruta) {
		try {
			f = new File(ruta);
			fis = new FileInputStream(f);
			isr = new InputStreamReader(fis);
			br = new BufferedReader(isr);
			nextLine();
		} catch (Exception e) {
			System.out.println("Error creando el archivo en FileParser");
			e.printStackTrace();
		}
	}

	public boolean eof(){
		String l = this.getLine();
		return (l == null); 
	}

	public void nextLine()
	{
		String l = "";
		try {
			l = this.getBr().readLine();
		} catch (IOException e) {
			System.out.println("Error en nextLine haciendo el readLine");
			e.printStackTrace();
		} 
		this.line = l;
	}

	public void closeFile(){
		try {
			this.getBr().close();
		} catch (IOException e) {
			System.out.println("Error cuando cierro el archivo en FileParser");
			e.printStackTrace();
		}
	}
	
	public BufferedReader getBr() {
		return br;
	}

	public void setBr(BufferedReader br) {
		this.br = br;
	}

	public File getF() {
		return f;
	}

	public void setF(File f) {
		this.f = f;
	}

	public String getLine() {
		return line;
	}

	public void setLine(String line) {
		this.line = line;
	}
	
}
